<template>
	<view class="detail_page">
		<view class="go-home" @click="backHome">
			<image :src="imglink + 'home/home-Selected.png'" mode=""></image>
		</view>
		<view class="detail_msg">
			<view class="">
				 <swiper class="swiper" :indicator-dots="indicator_dots" :autoplay="autoplay" :interval="interval" :duration="duration">
					<swiper-item v-for="item in itemAct.image" :key='item.activity_image_id'>
						<image :src="item.image ||item" mode=""></image>
					</swiper-item>
				</swiper>
				<image class="share" :src="imglink + 'home/share.png'" mode="" @click="sharePoster"></image>
				<image class="contact" :src="imglink + 'home/contact.png'" mode=""  @click="popupSwitch('open','contact')"></image>
			</view>
			<view class="detail_msg_time">
				<view class="act_title">
					{{itemAct.name | goodName}}
				</view>
				<view class="act_time">
					<view class="act_time_tip">
						活动结束倒计时：
					</view>
					<view class="act_time_det">
						<text>{{d}}</text>
						天
						<text>{{h}}</text>
						时
						<text>{{min}}</text>
						分
						<text>{{sec}}</text>
						秒
					</view>
				</view>
				<view class="act_num" v-if="options.page != 'preview'">
					<view class="act_num_map">
						<image :style="{left:mWidth + '%'}" :src="imglink + 'home/location-icon.png'" mode=""></image>
						<view class="botline">  <!-- 底下的进度条 -->
							<view class="topline" :style="{width:width + '%'}"></view>  <!-- 里面的显示百分比的进度条 -->
						</view>
						<view class="act_num_detail">
							<view class="">
								{{(itemAct.virtual_total + itemAct.participants) || 0}}人已参与
							</view>
							<view class="">
								剩余名额<text>{{(itemAct.allowed_total - (itemAct.participants + itemAct.virtual_total)) || 0}}</text>个
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 活动详情 -->
		<view class="act_explain" v-if="isGroup=='group'">
			<view class="act_explain-title">
				<view class="explain-title">
					<view class=""></view>
					<view class="">
						活动说明
					</view>
				</view>
				<view class="explain_tip" @click="popupSwitch('open','group')">
					<text>活动详情</text>
					<image :src="imglink + 'home/arrow-right.png'" mode=""></image>
				</view>
			</view>
			<view class="act_content">
				<text>1.发起拼团</text>
				>
				<text>2.邀请团员</text>
				>
				<text>3.拼团成功</text>
				>
				<text>4.兑换课程</text>
			</view>
		</view>
		<!-- 团长福利 -->
		<view class="act_explain" v-if=" isGroup=='group' && enable_head_welfare == 1" style="height: 230upx;">
			<view class="act_explain-title">
				<view class="explain-title">
					<view class=""></view>
					<view class="">
						团长福利
					</view>
				</view>
				<view class="explain_tip" @click="popupSwitch('open','welfare')">
					<text>福利详情</text>
					<image :src="imglink + 'home/arrow-right.png'" mode=""></image>
				</view>
			</view>
			<view class="welfare_content">
				团长福利团长福利团长福利团长福利福利团长福利福利团长福利福利团长福利福利团
			</view>
		</view>
		<!-- 课程类型 -->
		<view class="course_type">
			<view class="course_type-title">
				<view class="act-state-detail">
					参与活动课程
				</view>
				<view class="act-state-tip" v-if="itemAct.enable_allowed_purchase_quantity== '1'">
					本活动每个人限报{{itemAct.allowed_purchase_quantity}}个课程
				</view>
			</view>
			<view class="course-details" v-for="(item,index) in itemAct.course_msg" :key='item.activity_course_id'>
				<view class="suspend-title">课程{{index+1}}</view>
				<view class="course-details-title">
					<!-- 新东方GRE课程8节线下体验课，双十二特权活动特权活动特权活动特权活动权活动特权活动特权活动特权活动 -->
					{{item.name | goodName_val}}
				</view>
				<view class="course-details-content">
					<view class="course-content-left">
						<image class="course-content_img" :src="item.image || item.imageMainCourse" mode=""></image>
						<view class="">
							<view class="course-content-sold" :style="{marginBottom:isGroup?'16upx':''}">市场价:<text>￥{{item.origin_price}}</text></view>
							<view class="course-content-sale" >优惠价:<text :style="{fontSize:isGroup?'32upx':''}">￥{{item.special_price}}</text></view>
							<view class="group-sale" v-if="isGroup"><text>{{quanlity_group_purchase}}</text>人成团价:<text>￥{{item.group_purchase_price}}</text></view>
						</view>
					</view>
					<view class="course-content-right">
						<view class="">
							购买数量
						</view>
						<view class="">
							<image :src="imglink + 'home/reduce_black.png'" mode="" @click="reduceNum(item)"></image>
							<text>{{item.courseNum}}</text>
							<image :src="imglink + 'home/add-colours.png'" mode=""  @click="addNum(item)"></image>
						</view>
					</view>
				</view>
				<view class="course-details-tip">
					<view class="">1000人已参加</view>
					<view class="">每个人限报<text>{{item.limit_course}}</text>次</view>
				</view>
				<view class="privilege" v-if="item.give_cash_shopping_card_to_parents == '1'">
					<image :src="imglink + 'home/shop-card.png'" mode=""></image>
					<view class="">
						限量特权，再赠送 ¥{{item.cash_shopping_card_amount}} 购物卡！
					</view>
				</view>
				<view class="course-content" v-if="item.isCourseShow">
					<view class="course-content-addr" v-for="(info,num) in item.all_salesroom" :key='info.customer_organization_salesroom_id' v-if="info.length!=0">
						<view class="">
							<text><!-- 龙岗门店1 -->{{info[0].name | addr_value}}</text>
							{{info[0].province_id + '省'+info[0].city_id + info[0].country_id + info[0].address | address_value}}
						</view>
						<view class="">
							<image :src="imglink + 'home/location-icon-img.png'" mode=""></image>
						</view>
					</view>
					<view :style="{heigth:info.image!=null || info.type == 'photo'?'height: 344upx;':''}" class="course-content-img" 
					v-for="(info,i) in item.activity_course_description" :key='i+1' v-if="item.activity_course_description.length!=0">
						<image :src="info.image || info.value" mode="" v-if="info.image!=null || info.type == 'photo'"></image>
						<view class="course-content-tip" v-else>
							<!-- 占地3000平方米，15个名师，3个机构 -->{{info.text || info.value}}
						</view>
					</view>
				</view>
				<view class="check-details"  v-if="!item.isCourseShow" @click="checkClick(item)">
					查看详情
					<image :src="imglink + 'home/check-details.png'" mode=""></image>
				</view>
				<view class="check-details" v-if="item.isCourseShow" @click="packClick(item)">
					收起详情
					<image :src="imglink + 'home/check-details.png'" mode="" style="transform: rotate(180deg);"></image>
				</view>
			</view>
		</view>
		<!-- 活动说明 -->
		<view class="act-state" v-if="showActDetail">
			<view class="course_type-title">
				<view class="act-state-detail">
					活动说明
				</view>
				<!-- <view class="act-state-tip" style="color: #999999;width: 432upx;">
					双十二活动，特惠活动，只限新用户参加
				</view> -->
			</view>
			<view class="course-contain" v-for="(info,j) in itemAct.activity_description" :key='j'>
				<!-- <view class="">
					课程详情
				</view> -->
				<view class="" v-if="info.description_type == 0 || info.type == 'text'">
					{{info.value}}
				</view>
				<image :src="info.value" mode="" v-else></image>
			</view>
		</view>
		<!-- 门店活动地址 -->
		<view class="shop-addr" v-if="storeList.length!=0">
			<view class="course_type-title">
				<view class="act-state-detail">
					门店活动地址
				</view>
				<view class="act-state-tip" style="color: #999999;">
					参与活动的门店地址
				</view>
			</view>
			<view class="shop-addr-details">
				<view class="shop-details" v-for="(item,index) in storeList" :key='index'>
					<view class="">
						<text>{{item.name | addr_value}}</text>
						{{item.addressContent | address_value}}
					</view>
					<view class="">
						<image :src="imglink + 'home/location-icon-img.png'" mode=""></image>
					</view>
				</view>
				<!-- <view class="shop-details">
					<view class="">
						<text>龙岗门店2</text>
						深圳市龙岗区龙岗中心城优优岛教育成1楼教育成1楼
					</view>
					<view class="">
						<image :src="imglink + 'home/location-icon-img.png'" mode=""></image>
					</view>
				</view>
				<view class="shop-details">
					<view class="">
						<text>龙岗门店3</text>
						深圳市龙岗区龙岗中心城优优岛教育成1楼教育成1楼
					</view>
					<view class="">
						<image :src="imglink + 'home/location-icon-img.png'" mode=""></image>
					</view>
				</view>
				<view class="shop-details">
					<view class="">
						<text>龙岗门店4</text>
						深圳市龙岗区龙岗中心城优优岛教育成1楼教育成1楼
					</view>
					<view class="">
						<image :src="imglink + 'home/location-icon-img.png'" mode=""></image>
					</view>
				</view> -->
			</view>
		</view>
		<view class="" style="position: fixed;bottom: 0;left: 0;width: 100%;" v-if="isGroup=='group' && options.page != 'preview'">
			<view class="discounts-tip" v-if="itemAct.enable_purchase_course_then_give_course == '1' && isShowGiveTooltip">
				<image :src="imglink + 'home/give-icon.png'" mode=""></image>
				<view class="">
					再选择<text>{{itemAct.purchase_course}}</text>项，可送<text>{{itemAct.purchase_course}}</text>项
				</view>
			</view>
			<view class="course-bottom">
				<view class="shop-course" @click="carPopup">
					<view class="" :style="{marginTop:itemAct.enable_purchase_course_then_give_course == '0'?'10upx':''}">
						<image :src="imglink + 'home/give-gift.png'" mode=""></image>
						<text>{{ courseAmount }}</text>
					</view>
					<view class="" v-if="itemAct.enable_purchase_course_then_give_course == '1'">报{{itemAct.give_course}}科赠{{itemAct.purchase_course}}科</view>
				</view>
				<view class="money-case" :style="{'marginLeft':isShowOtherGroup?'0':'170upx'}">
					<view class="apply-now" @click="orderClick">
						<text class="money-details">￥{{totalOriginPrice.toFixed(2)}}</text>
						<text class="money-title">单独报名</text>
					</view>
					<view class="offered-join" v-if="isShowOtherGroup">
						<text class="money-details">￥{{totalWholesalePayPrice.toFixed(2)}}</text>
						<text class="money-title">参与拼团</text>
					</view>
					<view class="offered-open" @click="joinGroup">
						<text class="money-details">￥{{totalWholesalePayPrice.toFixed(2)}}</text>
						<text class="money-title">自己开团</text>
					</view>
				</view>
			</view>
		</view>
		<view class="preview-css" v-if="options.page == 'preview'">
			<view class="" @click="comeBack">
				关闭预览
			</view>
		</view>
		<view class="" style="position: fixed;bottom: 0;left: 0;width: 100%;" v-if="isGroup=='discount' && options.page != 'preview'">
			<view class="discounts-tip" v-if="itemAct.enable_purchase_course_then_give_course == '1' && isShowGiveTooltip">
				<image :src="imglink + 'home/give-icon.png'" mode=""></image>
				<view class="">
					再选择<text>{{itemAct.purchase_course}}</text>项，可送<text>{{itemAct.purchase_course}}</text>项
				</view>
			</view>
			<view class="course-bottom">
				<view class="shop-course" @click="carPopup">
					<view class="" :style="{marginTop:itemAct.enable_purchase_course_then_give_course == '0'?'10upx':''}">
						<image :src="imglink + 'home/give-gift.png'" mode=""></image>
						<text>{{ courseAmount }}</text>
					</view>
					<view class="" v-if="itemAct.enable_purchase_course_then_give_course == '1'">报{{itemAct.give_course}}科赠{{itemAct.purchase_course}}科</view>
				</view>
				<view class="welfare_num">¥{{totalOriginPrice.toFixed(2)}}</view>
				<view class="sign-join" @click="orderClick">
					立即报名
				</view>
			</view>
		</view>
		<!-- 拼团活动说明弹框 -->
		<uni-popup ref="groupState" :custom="true">
			<view class="popup_box_de">
				<image class="popup_box_close" :src="imglink + 'home/popup-close.png'" @click="popupSwitch('close','group')"></image>
				<view class="popup_box_content">
					<view class="popup_box_top">
						<view class=""></view>
						<view class="">拼团规则说明</view>
						<view class=""></view>
					</view>
					<view class="popup_box_title">
						
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 团长福利说明 -->
		<uni-popup ref="welfareState" :custom="true">
			<view class="popup_box_de">
				<image class="popup_box_close" :src="imglink + 'home/popup-close.png'" @click="popupSwitch('close','welfare')"></image>
				<view class="popup_box_content">
					<view class="popup_box_top">
						<view class=""></view>
						<view class="">团长福利说明</view>
						<view class=""></view>
					</view>
					<view class="popup_box_title">
						{{head_welfare_content}}
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 联系老师弹框 -->
		<uni-popup ref="contactPopup" :custom="true">
			<view class="popup_box_de" style="height: 996upx;">
				<image class="popup_box_close" :src="imglink + 'home/popup-close.png'" @click="popupSwitch('close','contact')"></image>
				<view class="popup_box_content" style="top: 62upx;">
					<view class="teacher-code">
						<view class="teacher-code-title">
							<view class="pupop-line"></view>
							<view class="teacher-code-title-detail">联系老师</view>
							<view class="pupop-line"></view>
						</view>
						<view class="teacher-code-tip">有任何问题，请咨询老师</view>
						<view class="teacher-code-content" id="posterImg">
							<view class="teacher-code-content-tip" id="textBg">长按下面二维码，添加老师微信</view>
							<image :src="teacherWay.wechat_qrcode" mode="" id="qrCode"></image>
							<view class="teacher-code-add" id="text3">
								添加老师微信请备注<text>“活动报名”</text>
							</view>
						</view>
					</view>
					<view class="teacher-phone" style="padding: 0 30upx;box-sizing: border-box;">
						<view class="teacher-phone-title">
							<text>老师联系电话</text>
							<view class="" @click="callPhone">
								<image :src="imglink + 'home/phone-icon.png'" mode=""></image>
								<text>拔打电话</text>
							</view>
						</view>
						<view class="teacher-phone-content">
							{{teacherWay.changePhone}}
						</view>
						<view class="" style="color: #999999;text-align: center;font-size: 24upx;margin-top: 10upx;">
							电话接通，请告知“活动报名"
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 科目购物车弹框 -->
		<uni-popup ref="shoppingPopup" :custom="true" type="bottom">
			<view class="popup_shopping">
				<view class="popup_shopping-content">
					<view class="course_type-title" style="height: 200upx;">
						<view class="act-state-detail">
							已报名课程
						</view>
						<view class="act-state-tip">
							本活动每个人限报{{itemAct.enable_purchase_course_then_give_course}}个课程
						</view>
					</view>
					<view v-if="courseAmount != 0">
						<scroll-view scroll-y="true" scroll-with-animation :style="'height:'+height+'px'" >
							<view class="popup_shopping-details" v-if="item.courseNum != 0" v-for="(item,index) in itemAct.course_msg" :key='index'>
								<view class="popup_shopping-title">
									{{item.name |goodName_val}}
								</view>
								<view class="course-details-content">
									<view class="course-content-left">
										<image class="course-content_img" :src="item.image || item.imageMainCourse" mode=""></image>
										<view class="">
											<view class="course-content-sold" :style="{marginBottom:isGroup?'16upx':''}">市场价:<text>￥{{item.origin_price}}</text></view>
											<view class="course-content-sale" >优惠价:<text :style="{fontSize:isGroup?'32upx':''}">￥{{item.special_price}}</text></view>
											<view class="group-sale" v-if="isGroup"><text>{{itemAct.group_purchase[0].quanlity_group_purchase}}</text>人成团价:<text>￥{{item.group_purchase_price}}</text></view>
										</view>
									</view>
									<view class="course-content-right">
										<view class="">
											购买数量
										</view>
										<view class="">
											<image :src="imglink + 'home/reduce_black.png'" mode="" @click="reduceNum(item)"></image>
											<text>{{item.courseNum}}</text>
											<image :src="imglink + 'home/add-colours.png'" mode=""  @click="addNum(item)"></image>
										</view>
									</view>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="course-bottom" style="margin-top: 40upx;" v-if="isGroup">
					<view class="shop-course" @click="carPopupClose">
						<view class="">
							<image :src="imglink + 'home/give-gift.png'" mode=""></image>
							<text>{{ courseAmount }}</text>
						</view>
						<view class="" v-if="itemAct.purchase_course == '1'">报{{itemAct.give_course}}科赠{{itemAct.purchase_course}}科</view>
					</view>
					<view class="money-case" :style="{'marginLeft':isShowOtherGroup?'0':'170upx'}">
						<view class="apply-now" @click="orderClick">
							<text class="money-details">￥{{totalOriginPrice.toFixed(2)}}</text>
							<text class="money-title">单独报名</text>
						</view>
						<view class="offered-join" v-if="isShowOtherGroup">
							<text class="money-details">￥{{totalWholesalePayPrice.toFixed(2)}}</text>
							<text class="money-title">参与拼团</text>
						</view>
						<view class="offered-open" @click="joinGroup">
							<text class="money-details">￥{{totalWholesalePayPrice.toFixed(2)}}</text>
							<text class="money-title">自己开团</text>
						</view>
					</view>
				</view>
				<view class="" style="margin-top: 40upx;" v-if="!isGroup">
					<view class="course-bottom">
						<view class="shop-course" @click="carPopupClose">
							<view class="">
								<image :src="imglink + 'home/give-gift.png'" mode=""></image>
								<text>{{courseAmount}}</text>
							</view>
							<view class="">报3科赠1科</view>
						</view>
						<view class="welfare_num">¥{{totalOriginPrice.toFixed(2)}}</view>
						<view class="sign-join" @click="orderClick">
							立即报名
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '../../../components/uni-popup/uni-popup.vue'
	import {formatFullTime} from '@/common/util.js'
	export default{
		filters: {
			goodName_val(value) {
				if (!value) return ''
				if (value.length > 40) {
					return value.slice(0, 40) + '...'
				}
				return value
			},
			goodName(value) {
				if (!value) return ''
				if (value.length > 38) {
					return value.slice(0, 38) + '...'
				}
				return value
			},
			addr_value(value) {
				if (!value) return ''
				if (value.length > 4) {
					return value.slice(0, 4) + '...'
				}
				return value
			},
			address_value(value) {
				if (!value) return ''
				if (value.length > 28) {
					return value.slice(0, 28) + '...'
				}
				return value
			},
		},
		components:{uniPopup},
		data(){
			return{
				imglink: this.$store.state.imgLink,
				store_id:0,//店铺id
				activity_id:0,//活动id
				width:0,//宽度
				mWidth:0,//最小宽度
			    indicator_dots: true,//轮播图是否显示...
				autoplay: false,//是否自动播放
				interval: 2000,//播放间隔
				duration: 500,//持续时间
				isCourseShow:false,
				courseAmount:0,
				activity:null,
				startEnd:"",//时间差
				countDown:'',//离结束时间倒计时
				currentTime:'',//当前时间
				d:'',//倒计时天数
				h:'',//倒计时小时
				min:'',//倒计时分钟
				sec:'',//倒计时秒,
				t1:null,//倒计时
				activityTime:true,
				teacherWay:{},
				storeList:[],
				isGroup:'',
				enable_head_welfare:'',
				head_welfare_content:'',
				quanlity_group_purchase:'',
				totalOriginPrice:0,
				totalWholesalePayPrice:0,
				height:300,
				currentPge:'',
				showActDetail:true,
				isShowGiveTooltip:false,
				isShowOtherGroup:false
			}
		},
		onLoad(options) {
			
			let store_id = parseInt(options.store_id,10);
			if(!store_id>0){
				store_id = uni.getStorageSync('store_id')
			}else{
				uni.setStorageSync('store_id', store_id)
			}
			this.store_id = store_id
			this.$store.commit('updateStoreId',store_id)
			
			let activity_id = parseInt(options.id,10);
			if(!activity_id>0){
				uni.redirectTo({
					url: '/pages/home/home?store_id='+ this.store_id
				})
			}
			this.activity_id = activity_id
			console.log('activity_id',activity_id);
			
			let token = options.token;
			if(!token){
				token = uni.getStorageSync('token')
			}else{
				uni.setStorageSync('token', token);
			}
			this.token = token
			this.$store.commit('updateToken',token)
			
			this.height = parseInt(uni.getSystemInfoSync().windowHeight) - this.height
			
		},
		onShow() {
			
			this.getActivity();
			
		},
		methods:{
			
			getActivity(activity_id){
				
				const data = {
					activity_id:this.activity_id,
				}
				
				this.$api.get_activity(data).then(res => {
					console.log('get_activity',res)
					if(res.status){
						
						this.activity = res.activity
						
						this.fullTime(this.activity.end_date)
						if(parseInt(this.activity.allowed_total,10)>0){
							this.width = Math.round((this.activity.virtual_total + this.activity.participants) / this.activity.allowed_total * 10000) / 100.00
						}
						this.width>100?this.width = 100:this.width=this.width
						if (this.width >= 92) {
							this.mWidth = 78
						} else {
							this.mWidth = this.width - 2<0?0:this.width - 2
						}
						
						if(this.activity.group_purchase.length>0){
							
							if(this.activity.group_purchase[0].show_other_group_purchase=='1'){
								this.isShowOtherGroup = true
							}else{
								this.isShowOtherGroup = false
							}
						}
						
						
						let array = []
						this.activity.course_msg.forEach(item => {
							item.courseNum = '0'
							item.originPrice = 0
							item.wholesalePayPrice = 0
							item.all_salesroom.forEach(info => {
								if(info[0]!= undefined){
									array.push(info[0])
								}
							})
						})
						
						if(this.activity.activity_description.length!=0){
							this.showActDetail = true
						}else{
							this.showActDetail = false
						}
						
						for(let i=0;i<array.length;i++){
							let flag =true
							for(let j=0;j<this.storeList.length;j++){
								if(this.storeList[j].customer_organization_salesroom_id == array[i].customer_organization_salesroom_id){
									flag = false
								}
							}
							if(flag){
								this.storeList.push(array[i])
							}
						}
						
						this.storeList.forEach(item =>{
							item.addressContent = item.province_id + '省'+item.city_id + item.country_id + item.address
						})
						
						if(this.activity.group_purchase.length == 0){
							this.isGroup = false
						}else{
							this.isGroup = true
							this.enable_head_welfare = this.activity.group_purchase[0].enable_head_welfare
							this.head_welfare_content =  this.activity.group_purchase[0].head_welfare_content
							this.quanlity_group_purchase = this.activity.group_purchase[0].quanlity_group_purchase
						}
						
					}
				})
				
			},
			
			backHome(){
				if(this.options.page == 'preview'){
					uni.showToast({
						title:'预览界面不可操作',
						icon:'none',
						duration:2000
					})
					return false
				}
				uni.navigateTo({
					url:'../home?store_id=' + this.store_id
				})
			},
			callPhone(){
				uni.makePhoneCall({
					phoneNumber:this.teacherWay.telephone,
					success(res) {
						console.log(res)
					},
					fail(err) {
						console.log(err)
					}
				})
			},
			// 获取所有活动信息
			getActList(){
				let data = {
					activity_id:this.options.id
				}
				this.$api.gain_all_act(data).then(res => {
					console.log('gain_all_act',res)
					if(res.status){
						this.itemAct = res.list.data[0]
						console.log(this.itemAct)
						this.fullTime(this.itemAct.end_date)
						if(parseInt(this.itemAct.allowed_total,10)>0){
							this.width = Math.round((this.itemAct.virtual_total + this.itemAct.participants) / this.itemAct.allowed_total * 10000) / 100.00
						}
						this.width>100?this.width = 100:this.width=this.width
						if (this.width >= 92) {
							this.mWidth = 78
						} else {
							this.mWidth = this.width - 2<0?0:this.width - 2
						}
						
						let array = []
						this.itemAct.course_msg.forEach(item => {
							item.courseNum = '0'
							item.originPrice = 0
							item.wholesalePayPrice = 0
							item.all_salesroom.forEach(info => {
								if(info[0]!= undefined){
									array.push(info[0])
								}
							})
						})
						
						if(this.itemAct.activity_description.length!=0){
							this.showActDetail = true
						}else{
							this.showActDetail = false
						}
						
						for(let i=0;i<array.length;i++){
							let flag =true
							for(let j=0;j<this.storeList.length;j++){
								if(this.storeList[j].customer_organization_salesroom_id == array[i].customer_organization_salesroom_id){
									flag = false
								}
							}
							if(flag){
								this.storeList.push(array[i])
							}
						}
						
						this.storeList.forEach(item =>{
							item.addressContent = item.province_id + '省'+item.city_id + item.country_id + item.address
						})
						
						if(this.itemAct.group_purchase.length == 0){
							this.isGroup = 'discount'
						}else{
							this.isGroup = 'group'
							if(this.itemAct.group_purchase[0].show_other_group_purchase=='1'){
								this.isShowOtherGroup = true
							}else{
								this.isShowOtherGroup = false
							}
							this.enable_head_welfare = this.itemAct.group_purchase[0].enable_head_welfare
							this.head_welfare_content =  this.itemAct.group_purchase[0].head_welfare_content
							this.quanlity_group_purchase = this.itemAct.group_purchase[0].quanlity_group_purchase
						}
						this.gainTeacher()
					}else{
						
						uni.showToast({
							title:res.msg,
							icon:"none",
							duration:2000
						})
						
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取老师联系方式
			gainTeacher(){
				// return new Promise((resolve, reject) => {
					let data = {
						token:this.token,
						activity_id:this.activity_id
					}
					this.$api.gain_teacher_contact(data).then(res => {
						console.log(res)
						if(res.status){
							this.teacherWay = res.data
							this.teacherWay.changePhone = this.teacherWay.telephone.replace(/(^\d{3}|\d{4}\B)/g,"$1-")
						}
					}).catch(err => {
						reject()
						console.log(err)
					})
				// })
			},
			reduceNum(item){
				let giveNum = 0
				if(this.options.page == "preview"){
					uni.showToast({
						title:'预览界面不可操作',
						icon:'none',
						duration:2000
					})
					return false
				}
				if(item.courseNum == '0'){
					item.originPrice = 0
					item.wholesalePayPrice = 0
					return false
				}else{
					item.courseNum--
					this.courseAmount --
					item.originPrice = item.originPrice - 1*item.special_price
					item.wholesalePayPrice = item.wholesalePayPrice - 1 * item.group_purchase_price 
					this.totalOriginPrice = this.totalOriginPrice - 1*item.special_price
					this.totalWholesalePayPrice = this.totalWholesalePayPrice - 1 * item.group_purchase_price 
					if(this.courseAmount==0){
						this.totalOriginPrice = 0
						this.totalWholesalePayPrice = 0
					}
					giveNum = parseInt(this.courseAmount/(this.itemAct.give_course + this.itemAct.purchase_course))
					console.log(this.courseAmount == (this.itemAct.give_course + this.itemAct.purchase_course)*(giveNum+1) - 1)
					if(this.courseAmount == (this.itemAct.give_course + this.itemAct.purchase_course)*(giveNum+1) - this.itemAct.purchase_course){
						this.isShowGiveTooltip = true
					}else{
						this.isShowGiveTooltip = false
					}
				}
			},
			addNum(item){
				let giveNum = 0 //赠送数量值
				// let course = []
				if(this.options.page == "preview"){
					uni.showToast({
						title:'预览界面不可操作',
						icon:'none',
						duration:2000
					})
					return false
				}
				if(item.courseNum >= item.limit_course){
					uni.showToast({
						title:'仅允许报' + item.limit_course + '次',
						icon:'none',
						duration:2000
					})
					return false
				}else{
					parseInt(item.courseNum++)
					this.courseAmount = this.courseAmount + 1
					item.originPrice = item.originPrice + 1*item.special_price 
					item.wholesalePayPrice = item.wholesalePayPrice + 1 * item.group_purchase_price 
					this.totalOriginPrice = this.totalOriginPrice + 1*item.special_price 
					this.totalWholesalePayPrice = this.totalWholesalePayPrice + 1 * item.group_purchase_price 
					giveNum = parseInt(this.courseAmount/(this.itemAct.give_course + this.itemAct.purchase_course))
					console.log(giveNum,'111111')
					if(this.courseAmount == (this.itemAct.give_course + this.itemAct.purchase_course)*(giveNum+1) - this.itemAct.purchase_course){
						this.isShowGiveTooltip = true
					}else{
						this.isShowGiveTooltip = false
					}
				}
			},
		}
	}
</script>

<style>
	.go-home{
		width: 60upx;
		height: 60upx;
		border-radius: 50%;
		position: fixed;
		border: 1upx solid #DEDEDE;
		top: 30upx;right: 40upx;
		z-index: 999;
	}
	.go-home>image{
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}
	.teacher-phone-content{
		width: 100%;
		height: 64upx;
		line-height: 64upx;
		background: #F3F3F4;
		margin-top: 20upx;
		text-align: center;
	}
	.teacher-phone-title{
		width: 100%;
		display: flex;
		padding-left: 74upx;
		box-sizing: border-box;
		margin-top: 10upx;
	}
	.teacher-phone-title>text{
		color: #333333;
		font-size: 28upx;
	}
	.teacher-phone-title>view{
		width: 164upx;
		height: 40upx;
		background: linear-gradient(to right,#FE9543,#FF664F);
		box-shadow: 0 4upx 8upx 0 rgba(255, 105, 78, 0.3);
		border-radius: 4upx;
		text-align: center;
		line-height: 40upx;
		margin-left: 20upx;
	}
	.teacher-phone-title>view>image{
		width: 20upx;
		height: 20upx;
	}
	.teacher-phone-title>view>text{
		color: #FFFFFF;
		font-size: 24upx;
	}
	.teacher-code-add{
		color: #666666;
		font-size: 26upx;
		text-align: center;
	}
	.teacher-code-add>text{
		color: #FF391F;
	}
	.teacher-code-content>image{
		width: 324upx;
		height: 322upx;
		margin: 12upx auto;
		margin-left: 40upx;
	}
	.teacher-code-content-tip{
		color: #999999;
		font-size: 24upx;
		text-align: center;
	}
	.teacher-code-tip{
		text-align: center;
		color: #FFFFFF;
		font-size: 24upx;
		margin-top: 10upx;
	}
	.teacher-code{
		width: 100%;
		height: 650upx;
		background: linear-gradient(#FE9543,#FF664F);
		padding: 0 30upx;
		box-sizing: border-box;
	}
	.teacher-code-content{
		width: 100%;
		padding: 30upx 60upx;
		box-sizing: border-box;
		background: #FFFFFF;
		border-radius: 20upx;
		margin-top: 30upx;
	}
	.pupop-line{
		width: 84upx;
		height: 2upx;
		border-top: 2upx solid rgba(255,255,255,0.6);
		margin-top: 64upx;
	}
	.pupop-line:nth-child(1){
		margin-left: 84upx;
	}
	.teacher-code-title{
		display: flex;
	}
	.teacher-code-title-detail{
		color: #FFFFFF;
		font-size: 34upx;
		margin: 0 30upx;
		margin-top: 40upx;
	}
	.sign-join{
		width: 406upx;
		height: 88upx;
		line-height: 88upx;
		text-align: center;
		color: #FFFFFF;
		font-size: 28upx;
		background: linear-gradient(to right,#FE9543,#FF664F);
		border-radius: 44upx;
		box-shadow: 0 4upx 12upx 0 rgba(250, 176, 48, 0.55);
		margin-left: 60upx;
		margin-top: 12upx;
	}
	.welfare_num{
		color: #FF391F;
		font-size: 40upx;
		margin-left: 30upx;
		margin-top: 28upx;
	}
	.preview-css{
		position: fixed;
		bottom: 0;left: 0;
		width: 100%;
		height: 100upx;
		background: #FFFFFF;
		padding-top: 10upx;
		box-sizing: border-box;
		box-shadow: 0 -10upx 12upx 0 rgba(0,0,0,0.09);
	}
	.preview-css>view{
		width: 342upx;
		height: 80upx;
		line-height: 80upx;
		margin: 0 auto;
		border-radius: 60upx;
		font-size: 28upx;
		text-align: center;
		color: #FFFFFF;
		background: linear-gradient(to right,#FE9543,#FF664F);
		box-shadow: 0 4upx 12upx 0 rgba(250, 176, 48, 0.55);
	}
	.uni-popup{
		z-index: 888;
	}
	/* 购物车样式 */
	.popup_shopping{
		width: 100%;
		/* height: 100%; */
		padding-top: 30upx;
		box-sizing: border-box;
		background: #F5F5F5;
	}
	.popup_shopping-content{
		width: 100%;
		/* height: 70%; */
		background: #FFFFFF;
		padding: 0 30upx;
		padding-bottom: 30upx;
		box-sizing: border-box;
	}
	.popup_shopping-details{
		width: 100%;
		height: 288upx;
		background: #FFFFFF;
		box-shadow: 0 2upx 22upx rgba(0, 0, 0, 0.09);
		border-radius: 10upx;
		margin-top: 30upx;
		padding: 40upx 20upx 30upx;
		box-sizing: border-box;
	}
	.popup_shopping-title{
		color: #333333;
		font-size: 30upx;
	}
	/* 拼团规则弹框样式 */
	.popup_box_de{
		height: 924upx;
		width: 590upx;
		position: relative;
	}
	.popup_box_close{
		width: 52upx;
		height: 52upx;
		position: absolute;
		top: 0;
		right: 0;
	}
	.popup_box_content{
		width: 100%;
		height: 852upx;
		background: #FFFFFF;
		position: absolute;
		top: 72upx;left: 0;
		border-radius: 16upx;
		z-index: 999;
	}
	.popup_box_top{
		width: 100%;
		height: 128upx;
		background: url(https://tool.tuanhaoke.cn/static/image/home/popup-top-bg.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
	}
	.popup_box_top>view:first-child{
		margin-left: 94upx;
	}
	.popup_box_top>view:first-child,.popup_box_top>view:last-child{
		width: 82upx;
		border-top: 2upx solid #FFFFFF;
		margin-top: 64upx;
	}
	.popup_box_top>view:nth-child(2){
		color: #FFFFFF;
		font-size: 34upx;
		line-height: 128upx;
		margin: 0 20upx;
	}
	.popup_box_title{
		width: 100%;
		padding: 30upx 20upx;
		box-sizing: border-box;
		color: #666666;
		font-size: 30upx;
		text-indent: 60upx;
	}
	.popup_box_title>view>image{
		width: 100%;
		height: 100upx;
	}
	page{
		background: #F5F5F5;
	}
	.detail_page{
		width: 100%;
		height: 100%;
		padding-bottom: 200upx;
		box-sizing: border-box;
	}
	.detail_msg{
		width: 100%;
		/* height: 786upx; */
		background: #FFFFFF;
	}
	.detail_msg>view:first-child{
		width: 100%;
		height: 422upx;
		position: relative;
	}
	@keyframes imageEffect{
		from{opacity: 0.5;box-shadow: 0 8upx 16upx 0 rgba(255,255,255,0.3);}
		to{opacity: 1;box-shadow: 0 8upx 16upx 0 rgba(255,255,255,0.8)}
	}
	.contact{
		width: 80upx;
		height: 80upx;
		border-radius: 50%;
		position: fixed;
		right: 30upx;
		top: 202upx;
		z-index: 777;
		animation: imageEffect 2s infinite;
	}
	.share{
		width: 80upx;
		height: 80upx;
		position: fixed;
		border-radius: 50%;
		right: 30upx;
		top: 312upx;
		z-index: 777;
		animation: imageEffect 2s infinite;
	}
	.swiper,.swiper image{
		width: 100%;
		height: 100%;
	}
	.privilege{
		width: 100%;
		height: 60upx;
		border: 2upx solid #EAC77C;
		border-radius: 4upx;
		margin-top: 20upx;
		display: flex;
	}
	.privilege>image{
		width: 40upx;
		height: 46upx;
		margin-top: 6upx;
		margin-left: 20upx;
	}
	.privilege>view{
		color: #C3932D;
		font-size: 26upx;
		margin-left: 20upx;
		line-height: 60upx;
	}
	.detail_msg_time{
		width: 100%;
		/* height: 364upx; */
		padding: 0 30upx;
		padding-bottom: 30upx;
		box-sizing: border-box;	
	}
	.act_title{
		width: 100%;
		padding: 20upx 0;
		box-sizing: border-box;
		font-size: 34upx;
		color: #333333;
		border-bottom: 1upx solid #DEDEDE;
	}
	.act_time{
		margin-top: 34upx;
		display: flex;
	}
	.act_time_tip{
		color: #999999;
		font-size: 24upx;
		margin-top: 10upx;
	}
	.act_time_det{
		color: #666666;
		font-size: 28upx;
		margin-left: 10upx;
	}
	.act_time_det>text{
		display: inline-block;
		margin: 0 10upx;
		padding: 8upx;
		background: #FEEFE3;
		color:#FF391F;		font-size: 36upx;
		border-radius: 2upx;
	}
	.act_num{
		width: 100%;
		/* margin-top: 64upx; */
	}
	.botline{
		width: 100%;
		height: 16upx;
		border-radius: 10upx;
		background: #F1F1F2;
		margin-top: 56upx;
		/* opacity: 0.26; */
	}
	.topline{
		background: linear-gradient(to right,#FE9543,#FF664F);
		border-radius: 20upx;
		height: 16upx;
	}
	.act_num_map{
		position: relative;
	}
	.act_num_map>image{
		width: 32upx;
		height: 42upx;
		position: absolute;
		top: -50upx;
	}
	.act_num_detail{
		margin-top: 8upx;
		display: flex;
		justify-content: space-between;
	}
	.act_num_detail>view{
		color: #666666;
		font-size: 24upx;
	}
	.act_num_detail>view>text{
		color: #FF391F;
	}
	.act_explain{
		width: 100%;
		height: 180upx;
		background: #ffff;
		margin-top: 20upx;
		padding: 30upx;
		box-sizing: border-box;
	}
	.act_explain-title{
		display: flex;
		justify-content: space-between;
	}
	.explain-title{
		display: flex;
	}
	.explain-title>view:first-child{
		width: 8upx;
		height: 32upx;
		background: #FF8B46;
		vertical-align: middle;
		margin-top: 6upx;
	}
	.explain-title>view:last-child{
		color: #333333;
		font-size: 34upx;
		margin-left: 10upx;
	}
	.explain_tip{
		color: #999999;
		font-size: 24upx;
	}
	.explain_tip>image{
		width: 10upx;
		height: 20upx;
		margin-left: 10upx;
		vertical-align: middle;
	}
	.explain_tip>text{
		vertical-align: middle;
	}
	.act_content{
		font-size: 30upx;
		color: #999999;
		margin-top: 30upx;
	}
	.act_content>text{
		color: #333333;
		display: inline-block;
		margin: 0 6upx;
	}
	.act_content>text:first-child{
		margin-left: 0;
	}
	.act_content>text:last-child{
		margin-right: 0;
	}
	.welfare_content{
		color: #333333;
		font-size: 30upx;
		margin-top: 30upx;
	}
	.course_type{
		width: 100%;
		padding: 0 30upx 30upx 30upx;
		box-sizing: border-box;
		background: #FFFFFF;
		margin-top: 20upx;
	}
	.course_type-title{
		width: 100%;
		height: 100upx;
		position: relative;
	}
	.act-state-detail{
		width: 236upx;
		height: 66upx;
		background-image: url(https://tool.tuanhaoke.cn/static/image/home/home_image_background.png);
		background-repeat: no-repeat;
		background-size: 1005 100%;
		text-align: center;
		font-size: 30upx;
		color: #FFFFFF;
		line-height: 66upx;
		position: absolute;
		top: -4upx;left: 50%;
		transform: translate(-50%,0);
	}
	.act-state-tip{
		color: #FF391F;
		font-size: 24upx;
		position: absolute;
		top: 80upx;left: 50%;
		transform: translate(-50%,0);
	}
	.course-details{
		width: 100%;
		/* height: 400upx; */
		background: #FFFFFF;
		box-shadow: 0 2upx 22upx 0 rgba(0, 0, 0, 0.09);
		border-radius: 10upx;
		padding: 0 20upx;
		box-sizing: border-box;
		position: relative;
		margin-top: 40upx;
	}
	.suspend-title{
		width: 144upx;
		height: 72upx;
		line-height: 72upx;
		text-align: center;
		color: #FFFFFF;
		font-size: 28upx;
		background-image: url(https://tool.tuanhaoke.cn/static/image/home/home_image_back.png);
		background-repeat: no-repeat;
		background-size: 100% 100%;
		position: absolute;
		top: -30upx;left: -16upx;
	}
	.course-details-title{
		color: #333333;
		font-size: 30upx;
		padding-top: 40upx;
		box-sizing: border-box;
	}
	.course-details-content{
		display: flex;
		justify-content: space-between;
		margin-top: 20upx;
	}
	.course-content-left{
		display: flex;
		justify-content: center;
	}
	.course-content_img{
		width: 160upx;
		height: 120upx;
	}
	.course-content-left>view{
		margin-left: 20upx;
		font-size: 24upx;
	}
	.course-content-sold{
		color: #999999;
	}
	.course-content-sold>text{
		text-decoration: line-through;
	}
	.course-content-sale{
		color: #333333;
		margin-top: 10upx;
	}
	.course-content-sale>text{
		color: #FF391F;
	}
	.group-sale{
		color: #333333;
		margin-top: 8upx;
	}
	.group-sale>text{
		color: #FF391F;
	}
	.group-sale>text:last-child{
		font-size: 32upx;
	}
	.course-content-right{
		padding-top: 32upx;
		box-sizing: border-box;
	}
	.course-content-right>view:first-child{
		color: #999999;
		font-size: 24upx;
		text-align: center;
	}
	.course-content-right>view:last-child{
		width: 156upx;
		height: 48upx;
		line-height: 48upx;
		background: #F2F2F2;
		border-radius: 24upx;
		display: flex;
		color: #333333;
		font-size: 30upx;
		justify-content: space-between;
		margin-top: 6upx;
	}
	.course-content-right>view:last-child>image{
		width: 48upx;
		height: 48upx;
		border-radius: 50%;
	}
	.course-details-tip{
		display: flex;
		justify-content: space-between;
		margin-top: 6upx;
	}
	.course-details-tip>view{
		color: #999999;
		font-size: 24upx;
	}
	.course-details-tip>view>text{
		color: #FF391F;
	}
	.check-details{
		width: 100%;
		padding: 14upx 0;
		box-sizing: border-box;
		margin-top: 30upx;
		color: #999999;
		font-size: 24upx;
		text-align: center;
		vertical-align: middle;
		border-top: 1upx solid #DEDEDE;
	}
	.check-details>image{
		width: 28upx;
		height: 28upx;
		border-radius: 50%;
		margin-left: 10upx;
		vertical-align: middle;
	}
	.course-content{
		width: 100%;
		/* height: 612upx; */
		background: #F4F5F9;
		padding: 0 20upx;
		padding-top: 10upx;
		padding-bottom: 30upx;
		box-sizing: border-box;
		margin-top: 32upx;
	}
	.course-content-addr{
		/* height: 100upx; */
		display:flex;
		justify-content:space-between;
		padding : 20upx 0;
		box-sizing: border-box;
		border-bottom: 1upx solid #DEDEDE;
	}
	.course-content-addr>view>image{
		width:56upx;
		height:56upx;
		border-radius:50%;
		margin-top: 14upx;
	}
	.course-content-addr>view:first-child{
		width: 524upx;
		color: #333333;
		font-size: 28upx;
		/* line-height: 100upx; */
	}
	.course-content-addr>view:first-child>text{
		display: inline-block;
		width: 126upx;
		text-align: center;
		border: 1upx solid #FF8B46;
		color: #FF8B46;
		font-size: 24upx;
		margin-right: 20upx;
	}
	.course-content-img{
		width: 100%;
		margin-top: 30upx;
	}
	.course-content-img>image{
		/* width: auto;
		height: auto; */
		max-width: 100%;
		max-height: 100%;
	}
	.course-content-tip{
		margin-top: 20upx;
		color: #333333;
		font-size: 28upx;	}
	.act-state{
		width: 100%;
		/* height: 808upx; */
		background: #FFFFFF;
		margin-top: 20upx;
		padding: 0 30upx 30upx 30upx;
		box-sizing: border-box;
		position: relative;
	}
	.course-contain{
		width: 100%;
		padding: 0 20upx;
		box-sizing: border-box;
		text-align: left;
	}
	.course-contain>view{
		color: #333333;
		font-size: 30upx;
		margin-bottom: 10upx;
	}
	.course-contain>image{
		width: 100%;
		height: 600upx;
		margin-bottom: 10upx;
	}
	/* .course-contain>view:first-child{
		color: rgb(214, 97, 42);
	} */
	.shop-addr{
		width: 100%;
		position: relative;
		/* height: 742upx; */
		background: #FFFFFF;
		margin-top: 20upx;
		padding: 0 30upx 30upx 30upx;
		box-sizing: border-box;
		margin-bottom: 30upx;
	}
	.shop-addr-details{
		margin-top: 30upx;
	}
	.shop-details{
		display: flex;
		justify-content: space-between;
		padding: 30upx 0;
		box-sizing: border-box;
		border-top: 1upx solid #DEDEDE;
	}
	.shop-details:last-child{
		border-bottom: 1upx solid #DEDEDE;
	}
	.shop-details>view>image{
		width: 66upx;
		height: 66upx;
		border-radius: 50%;
	}
	.shop-details>view:first-child{
		width: 544upx;
		color: #333333;
		font-size: 30upx;
		/* margin-top: 10upx; */
	}
	.shop-details>view:first-child>text{
		display: inline-block;
		width: 120upx;
		line-height: 36upx;
		border: 1upx solid #FF8B46;
		color: #FF8B46;
		font-size: 24upx;
		text-align: center;
		margin-right: 10upx;
	}
	.discounts-tip{
		width: 100%;
		height: 64upx;
		line-height: 64upx;
		background: #FFF7D8;
		margin-top: 52upx;
		display: flex;
	}
	.discounts-tip>image{
		width: 40upx;
		height: 40upx;
		margin-left: 240upx;
		margin-top: 12upx;
	}
	.discounts-tip>view{
		color: #666666;
		font-size: 26upx;
		margin-left: 20upx;
	}
	.discounts-tip>view>text{
		color: #FF391F;
	}
	.course-bottom{
		width: 100%;
		height: 112upx;
		background: #FFFFFF;
		display: flex;
	}
	.shop-course{
		margin-left: 36upx;
		margin-top: 12upx;
	}
	.shop-course>view:first-child{
		position: relative;
		margin: 0 auto;
		height: 56upx;
	}
	.shop-course>view>image{
		width: 56upx;
		height: 56upx;
		margin-left: 32upx;
	}
	.shop-course>view>text{
		display: inline-block;
		width: 28upx;
		height: 28upx;
		border-radius: 50%;
		background: #FF391F;
		color: #FFFFFF;
		font-size: 24upx;
		line-height: 28upx;
		text-align: center;
		position: absolute;
		top: 0;right: 4upx;
	}
	.shop-course>view:last-child{
		color: #999999;
		font-size: 20upx;
		margin-top: 6upx;
	}
	.money-case{
		width: 570upx;
		height: 88upx;
		margin-top: 12upx;
		/* margin-left: 22upx; */
		border-radius: 44upx;
		display: flex;
		color: #FFFFFF;
		text-align: center;
	}
	.apply-now{
		width: 190upx;
		height: 100%;
		border-radius: 44upx 0 0 44upx;
		background: linear-gradient(to left,#F8AA37,#F8C334);
		padding-top: 4upx;
		box-sizing: border-box;
	}
	.offered-join{
		width: 190upx;
		height: 100%;
		background: linear-gradient(to left,#FBA130,#F7CC30);
		padding-top: 4upx;
		box-sizing: border-box;
	}
	.offered-open{
		width: 190upx;
		height: 100%;
		border-radius: 0 44upx 44upx 0;
		background: linear-gradient(to left,#F95723,#F87727);
		padding-top: 4upx;
		box-sizing: border-box;
	}
	.money-details,.money-title{
		display: block;
	}
	.money-details{
		font-size: 32upx;
	}
	.money-title{
		font-size: 28upx;
	}
</style>
